<template>
    <div>
        <h1>新增角色</h1>
        <tbody class="table">
        <tbody>
            <tr>
                <td>姓名</td>
                <td>
                    <input type="text" v-model="data.Uname">
                </td>
            </tr>
            <tr>
                <td>性别</td>
                <td>
                    <input v-model="data.Set" type="radio" name="Set" value="男">男
                    <input v-model="data.Set" type="radio" name="Set" value="女">女
                </td>
            </tr>
            <tr>
                <td>地址</td>
                <td>
                    <input type="text" v-model="data.Adress">
                </td>
            </tr>
            <tr>
                <td>生日</td>
                <td>
                    <input type="date" v-model="data.Barder">
                </td>
            </tr>
            <tr>
                <td>手机号</td>
                <td>
                    <input type="text" v-model="data.Phone">
                </td>
            </tr>
            <tr>
                <td>证件号</td>
                <td>
                    <input type="text" v-model="data.ZJH">
                </td>
            </tr>
            <tr>
                <td>职业类型</td>
                <td>
                    <select v-model="data.Tid">
                        <option value="0">选择职业</option>
                        <option v-for="d in Bang" :value="d.Tid">{{ d.Tname }}</option>
                    </select>

                </td>
                <tr>
                <td>证件类型</td>
                <td>
                    <select v-model="data.Zid">
                        <option value="-1">选择职业</option>
                        <option value="身份证">身份证</option>
                        <option value="军官证">军官证</option>
                        <option value="护照">护照</option>
                    </select>

                </td>
            </tr>
            </tr>
            <tr>
                <td>状态</td>
                <td>
                    <input v-model="data.Sarter" type="radio" name="Sarter" value="0">启用
                    <input v-model="data.Sarter" type="radio" name="Sarter" value="1">禁用
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <input type="button" class="btn btn-success" value="新增" @click="saveinfo">
                    <a href="/">返回会员列表</a>
                </td>
            </tr>
        </tbody>
        </tbody>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios'
import { ref, onMounted } from 'vue'
import { useRouter } from 'vue-router'
const router = useRouter()
onMounted(() => {
    bang();
})
const Bang = ref([{
    "Tid": 0,
    "Tname": ""
}])
const bang = () => {
    axios.get("/api/User/bang").then(res => {
        Bang.value = res.data
    })

}

const data = ref({
    "Uname": "",
    "Set": "",
    "Barder": "2025-06-26T01:47:50.562Z",
    "Phone": "",
    "ZJH": "",
    "Zid": 0,
    "Tid": 0,
    "Adress": "",
    "Sarter": 0
})
const saveinfo = () => {
    axios.post('/api/User/tianjia', data.value).then(res => {
        if (res.data > 0) {
            alert("新增成功")
            router.push("/showuser");
        }
        else {
            alert("新增失败...")
        }
    })
}
</script>

<style scoped></style>